﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Yookey.GSFJCSZF.IRepository;
using Yookey.GSFJCSZF.Models;

namespace EFCore.RazorPage.Pages
{
    public class IndexModel : PageModel
    {
        public IList<Demos> _listPosts { get; private set; }
        public Demos _post { get; private set; }


        private readonly IDemoRepository _demoRepository;
        public IndexModel(IDemoRepository demoRepository)
        {
            _demoRepository = demoRepository;
        }

        public async Task OnGetAsync()
        {
            _post = await _demoRepository.SelectSingle();
            _listPosts = await _demoRepository.SelectList("测试");
            //_listPosts = new List<Posts> {
            //    new Posts{ Id = Guid.NewGuid().ToString(),Title="第一个标题"},
            //    new Posts{ Id = Guid.NewGuid().ToString(),Title="第二个标题"}
            //};
        }
    }

    public class Posts
    {
        public string Id { get; set; }

        [Required, StringLength(100)]
        public string Title { get; set; }
    }
}
